package com.zhengtoudai.ui.presenter;

import com.zhengtoudai.http.HttpApi;
import com.zhengtoudai.injector.PerActivity;
import com.zhengtoudai.ui.bean.Result;
import com.zhengtoudai.ui.view.CommonView;

import javax.inject.Inject;

import rx.Observer;
import rx.functions.Action0;

/**
 * Created by Administrator on 2016/8/30 0030.
 */
@PerActivity
public class RequestTransferPresenterImpl extends BasePresenterImpl<CommonView> implements RequestTransferPresenter {

    @Inject
    public RequestTransferPresenterImpl(){

    }
    @Override
    public void requestTransfer(String transferMoney, String etenderId, String endTimeStr) {
        mSubscription=HttpApi.getInstance().requestTransfer(transferMoney,etenderId,endTimeStr)
                .doOnSubscribe(new Action0() {
                    @Override
                    public void call() {
                        mView.showDialog();
                    }
                }).subscribe(new Observer<Result>() {
            @Override
            public void onCompleted() {
                mView.dismissDialog();
            }

            @Override
            public void onError(Throwable e) {
                mView.onFailure(e);
                mView.dismissDialog();
            }

            @Override
            public void onNext(Result result) {
                mView.onResult(result);
            }
        });
    }
}
